#pragma once
#include <iostream>
#include <assert.h>
using namespace std;
namespace wang
{
	class string
	{
	public:
		using iterator = char*;
		using const_iterator = const char*;
		//string();
		//带参构造
		string(const char* str = "");
		//析构
		~string();
		//返回地址
		const char* c_str() const;
		//扩容
		void reserve(size_t n = 0);
		//插入一个字符
		void push_back(char ch);
		//插入一个字符串
		void append(const char* str);
		//+=一个字符
		string& operator+= (char ch);
		//+=一个字符串
		string& operator+= (const char* str);
		//operator[]
		char& operator[] (size_t index);
		const char& operator[] (size_t index) const;
		//size
		size_t size() const;
		//迭代器
		iterator begin();
		iterator end();
		//const迭代器
		const_iterator begin() const;
		const_iterator end() const;
		//交换
		void swap(string& s);
		//拷贝构造
		string(const string& s);
		//赋值
		string& operator= (string s);
		//比较大小
		bool operator< (const string& s);
		bool operator<= (const string& s);
		bool operator> (const string& s);
		bool operator>= (const string& s);
		bool operator== (const string& s);
		bool operator!= (const string& s);
		//pos位置插入字符
		void insert(size_t pos, char ch);
		//pos位置插入字符串
		void insert(size_t pos, const char* str);
		//删除pos位置开始的len个字符
		void erase(size_t pos, size_t len = npos);
		//从pos位置开始查找一个字符
		size_t find(char ch, size_t pos = 0);
		//从pos位置开始查找一个字符串
		size_t find(const char* str, size_t pos = 0);
		//获取从pos位置开始的len个字符
		string substr(size_t pos, size_t len = npos);
		//清除
		void clear();
	private:
		char* _str;
		int _size;
		int _capacity;
	public:
		static const size_t npos;
	};
	//交换
	void swap(string& s1, string& s2);
	//流提取
	ostream& operator<< (ostream& out, const string& s);
	//流插入
	istream& operator>> (istream& in, string& s);
	//getline
	istream& getline(istream& in, string& s, char delim = '\n');
}